#include <iostream>
#define LL long long
using namespace std;

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int T;

  for (cin >> T; T; T--) {
    int n, x;
    LL ans = 0;

    cin >> n >> x;

    for (int a = 1; a <= n; a++) {
      for (int b = 1;; b++) {
        if (a * b >= n || a + b >= x) {
          break;
        }

        int c = min(x - a - b, (n - a * b) / (a + b));

        ans += c;
      }
    }
    cout << ans << "\n";
  }
  return 0;
}